package com.gxp.system.service.impl;

import com.gxp.common.core.text.Convert;
import com.gxp.common.utils.DateUtils;
import com.gxp.common.utils.ShiroUtils;
import com.gxp.system.domain.ZknjApprove;
import com.gxp.system.mapper.ZknjApproveMapper;
import com.gxp.system.service.IZknjApproveService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 审计Service业务层处理
 * 
 * @author zh
 * @date 2024-10-08
 */
@Deprecated
@Service
public class ZknjApproveServiceImpl implements IZknjApproveService 
{
    @Autowired
    private ZknjApproveMapper zknjApproveMapper;

    /**
     * 查询审计
     * 
     * @param approveId 审计主键
     * @return 审计
     */
    @Override
    public ZknjApprove selectZknjApproveByApproveId(Long approveId)
    {
        return zknjApproveMapper.selectZknjApproveByApproveId(approveId);
    }

    /**
     * 查询审计列表
     * 
     * @param zknjApprove 审计
     * @return 审计
     */
    @Override
    public List<ZknjApprove> selectZknjApproveList(ZknjApprove zknjApprove)
    {
        return zknjApproveMapper.selectZknjApproveList(zknjApprove);
    }

    /**
     * 新增审计
     * 
     * @param zknjApprove 审计
     * @return 结果
     */
    @Override
    public int insertZknjApprove(ZknjApprove zknjApprove)
    {
        zknjApprove.setCreateTime(DateUtils.getNowDate());
        return zknjApproveMapper.insertZknjApprove(zknjApprove);
    }

    /**
     * 修改审计
     * 
     * @param zknjApprove 审计
     * @return 结果
     */
    @Override
    public int updateZknjApprove(ZknjApprove zknjApprove)
    {
        Long approveId = zknjApprove.getApproveId();
        String item = zknjApprove.getItem();
        switch (item){
            //todo
            case "Project":
                if(zknjApprove.getType().equals("Add Project")){
                    if(zknjApprove.getAprStatus() == 3){
                        //修改
                    }else if(zknjApprove.getAprStatus() == 4){

                    }
                }
                break;
            default:
                break;
        }
        return zknjApproveMapper.updateZknjApprove(zknjApprove);
    }

    /**
     * 批量删除审计
     * 
     * @param approveIds 需要删除的审计主键
     * @return 结果
     */
    @Override
    public int deleteZknjApproveByApproveIds(String approveIds)
    {
        return zknjApproveMapper.deleteZknjApproveByApproveIds(Convert.toStrArray(approveIds));
    }

    /**
     * 删除审计信息
     * 
     * @param approveId 审计主键
     * @return 结果
     */
    @Override
    public int deleteZknjApproveByApproveId(Long approveId)
    {
        return zknjApproveMapper.deleteZknjApproveByApproveId(approveId);
    }

    @Override
    public Long AddApprove(String approveType, String approveItem, String detail) {
        ZknjApprove approve = new ZknjApprove();
        approve.setItem(approveItem);
        approve.setType(approveType);
        approve.setDetail(detail);
        approve.setAprStatus(2L);
        approve.setCreateBy(ShiroUtils.getLoginName());
        approve.setCreateTime(DateUtils.getNowDate());
        zknjApproveMapper.insertZknjApprove(approve);
        return approve.getApproveId();
    }
}
